//正则验证
export function verify(inputName, value) {
    let result = null;
    switch (inputName) {
        case 'phone':
            let regPhone = /^1(3|4|5|7|8)\d{9}$/g;
            result = regPhone.test(value);
            break;
        case 'password':
            let regPassword = /.{6,20}$/g;
            result = regPassword.test(value);
            break;
        case 'name':
            let regName = /^[a-zA-Z][a-zA-Z0-9_]{3,15}$/g;
            // 返回布尔值成功为true
            result = regName.test(value);
        default:
            break;
    }
    return result;
}
//节流
export function throttle(callback, delay = 400) {
    let timer = null;
    return function () {
        if (timer) {
            clearInterval(timer);
        }

        timer = setTimeout(function () {
            callback();
        }, delay);
    };
}
